package com.easipass.epug.dao;

import com.easipass.epug.entity.DataTable;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Wangxuyang on 16/6/3.
 */
@Repository("dataTableDao")
public class DataTableDaoImp implements DataTableDao {
    @Resource
    private SessionFactory sessionFactory;

    public void add(DataTableDao dataTableDao) {
        this.sessionFactory.openSession().save(dataTableDao);
    }

    @SuppressWarnings("unchecked")
    public List<DataTable> getAll() {
        String sql = "from DataTable";
        Query query = this.sessionFactory.openSession().createQuery(sql);
        return query.list();
    }
}
